package com.inspur.edp.bef.bemanager.codegenerator.genutils;

import com.inspur.edp.bef.bizentity.GspBizEntityObject;
import com.inspur.edp.bef.bizentity.GspBusinessEntity;
import com.inspur.edp.bef.bizentity.operation.BizMgrAction;
import com.inspur.edp.bef.bizentity.operation.BizOperation;
import com.inspur.edp.bef.bizentity.operation.collection.BizMgrActionCollection;
import com.inspur.edp.cef.designtime.core.utilsgenerator.DataTypeUtilsGenerator;
import com.inspur.edp.cef.designtime.core.utilsgenerator.JavaAccessModifier;
import com.inspur.edp.cef.designtime.core.utilsgenerator.JavaClassInfo;
import com.inspur.edp.das.commonmodel.IGspCommonObject;

public final class BeMgrActionUtilsGenerator {
    private final GspBusinessEntity be;
    private String pachageName;
    private JavaClassInfo classInfo=new JavaClassInfo();
    public BeMgrActionUtilsGenerator(GspBusinessEntity be, String pachageName, String basePath) {
        this.be = be;
        classInfo.setFilePath(basePath);
        this.pachageName = pachageName;
    }

    protected String getClassName() {
        return this.be.getCode() + "MgrActionUtils";
    }

    public  final void generate()
    {
        classInfo.setPackageName(pachageName);
        classInfo.setClassName(getClassName());
        classInfo.getAccessModifiers().add(JavaAccessModifier.Public);
        classInfo.getAccessModifiers().add(JavaAccessModifier.Final);

        generateMgrMethod(be.getCustomMgrActions());
        classInfo.write2File();
    }

    private void generateMgrMethod(BizMgrActionCollection mgrActions) {
        if(mgrActions == null || mgrActions.size() == 0)
            return;
        for(BizOperation mrAction : mgrActions){
            new BeMgrActionMethodInvocationGenerator(this.be, (BizMgrAction) mrAction,classInfo).generate();
        }
    }
}
